(function(w) {
    function Alert(param) {
        this.title = param.title || '';
        this.content = param.content || '';
        this.alert = null;
        this.init();

        setTimeout(this.destroy.bind(this), param.time || 500);
    }

    Alert.prototype.init = function() {
        this.alert = document.createElement("div");
        this.alert.style.position = "absolute";
        this.alert.style.top = 0;
        this.alert.style.bottom = 0;
        this.alert.style.left = 0;
        this.alert.style.right = 0;
        this.alert.style.zIndex = 9999;

        var alert = document.createElement("div");
        alert.style.position = "absolute";
        alert.style.width = "250px";
        alert.style.height = "50px";
        alert.style.background = "grey";
        alert.style.zIndex = "9999";
        alert.style.top = 0;
        alert.style.bottom = 0;
        alert.style.left = 0;
        alert.style.right = 0;
        alert.style.margin = "auto";
        alert.style.opacity = 0.8;
        alert.style.textAlign = "center";
        alert.style.color = "#fff";
        alert.style.borderRadius = "5px";

        var title = document.createElement("div");
        title.style.position = "absolute";
        title.style.height = "15px";
        title.style.top = 0;
        title.innerHTML = this.title;

        var content = document.createElement("div");
        content.style.position = "absolute";
        content.style.width = alert.style.width;
        content.style.top = title.style.height;
        content.style.bottom = 0;
        content.style.textAlign = "center";
        content.style.fontSize = "16px";
        content.innerHTML = this.content;

        alert.appendChild(title);
        alert.appendChild(content);
        this.alert.appendChild(alert);

        document.body.appendChild(this.alert)
    };

    Alert.prototype.destroy = function() {
        document.body.removeChild(this.alert);
    };

    w.Alert = function(param) {
        return new Alert(param);
    }
})(window);
